Fix nan_random_v0 ignoring observation action masks - #275
Open
Doribelove wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nan_random_v0checks for"action mask"in the observation but then readsobs["action_mask"]. Observations using the standard underscore key therefore fall through to unmasked sampling. A NaN replacement can be illegal even when the observation identifies legal actions.Change the guard to
"action_mask", restoring the existing masked-sampling branch described in the wrapper documentation. Add two deterministic AEC regression cases with a single legal action; the seeded unmasked action space selects an illegal action in both cases. This addresses the NaN replacement path, which the existing normal-action API tests do not exercise.For an end-to-end reproduction with PettingZoo's Connect Four:
Before the fix, unmasked sampling selects the full column and terminates the game with an illegal-move penalty. After the fix, a legal column receives a piece and both termination flags remain false.
Validation on base
adf4114d0b437ba4607bd329ad32e34667c0a10b, using Python 3.12.14, NumPy 2.5.3, Gymnasium 1.3.0, and PettingZoo 1.27.0:git diff --check, and wheel/sdist builds passed.The two new regressions are included in the 77-test result. The full suite, Atari ROM tests, and the complete CI platform/Python matrix were not run locally.
AI assistance: Codex prepared the implementation, tests, and this description, and executed the reported local validation.